package na.learn.logging.sample;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;

import org.apache.log4j.xml.DOMConfigurator;

public class LoggerManager {

	private static String LogConfigFileLocation = null;

	static {
		System.out.println("Initializing Properties " );
		if (PropertiesManager.properties == null)
			PropertiesManager.init();

		LogConfigFileLocation = PropertiesManager.properties
				.getProperty(PropertiesManager.LogConfigFileLocation);
		DOMConfigurator.configureAndWatch(LogConfigFileLocation, 2000L);
		System.out.println("Completed Initializing Properties "  + LogConfigFileLocation);

	}

	public static String getLogConfigFileLocation() {
		return PropertiesManager.properties
				.getProperty(PropertiesManager.LogConfigFileLocation);
	}

	/*public static boolean setLogConfigFileLocation(String logConfigFileLocation) {

		try {
			// Check if file exists
			FileInputStream logConfigFile = new FileInputStream(
					"logConfigFileLocation");

			PropertiesManager.properties.setProperty(
					PropertiesManager.LogConfigFileLocation,
					logConfigFileLocation);
			LoggerManager.LogConfigFileLocation = logConfigFileLocation;

			return true;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return false;
		}

	}*/

}
